package com.ymatou.iapi.productsnapshot.testcase;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.productsnapshot.parameter.GetProductSnapshotOriginListBean;
import com.ymatou.iapi.productsnapshot.parameter.ProductSnapshotOriginDto;
import com.ymatou.iapi.productsnapshot.parameter.ProductVersionDto;
import com.ymatou.iapi.productsnapshot.service.GetProductSnapshotOriginListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.EnvSetup;
/**
*获取商品产地信息快照列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetProductSnapshotOriginList{
	private static GetProductSnapshotOriginListBean getproductsnapshotoriginlistBean;
	private static GetProductSnapshotOriginListCall getproductsnapshotoriginlistCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商品产地信息快照列表");
	}

	@Before
	public void caseUp() {
		getproductsnapshotoriginlistBean=new GetProductSnapshotOriginListBean();
		getproductsnapshotoriginlistCall=new GetProductSnapshotOriginListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getproductsnapshotoriginlistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductSnapshotOriginList_001() {
		Logger.start(true,"获取商品产地信息快照列表");
		try {
			//TODO 补全case代码
			
			List<ProductVersionDto> ProductVersionList = new ArrayList<>();
			
			ProductVersionDto productVersionDto1 = new ProductVersionDto();
			
			productVersionDto1.setProductId(EnvSetup.getData("productsnapshot_pid1"));
			productVersionDto1.setVersion(EnvSetup.getData("productsnapshot_ver1"));
			
			ProductVersionDto productVersionDto2 = new ProductVersionDto();

			productVersionDto2.setProductId(EnvSetup.getData("productsnapshot_pid2"));
			productVersionDto2.setVersion(EnvSetup.getData("productsnapshot_ver2"));
			
			ProductVersionDto productVersionDto3 = new ProductVersionDto();

			productVersionDto3.setProductId(EnvSetup.getData("productsnapshot_pid3"));
			productVersionDto3.setVersion(EnvSetup.getData("productsnapshot_ver3"));

			ProductVersionList.add(productVersionDto1);
			ProductVersionList.add(productVersionDto2);
			ProductVersionList.add(productVersionDto3);
			
			getproductsnapshotoriginlistBean.setProductVersionList(ProductVersionList);

			getproductsnapshotoriginlistCall.setData(getproductsnapshotoriginlistBean);
			getproductsnapshotoriginlistCall.callService();	
			
			Logger.verifyEquals("200", getproductsnapshotoriginlistCall.getString("Code"),"验证Code");
			
			List<ProductSnapshotOriginDto> SnapshotOriginList = getproductsnapshotoriginlistCall.getSnapshotOriginList().getSnapshotOriginList();
			
			Logger.verifyEquals(EnvSetup.getData("productsnapshot_value1"), SnapshotOriginList.get(0).getOrigin(),"验证Origin");
			Logger.verifyEquals(EnvSetup.getData("productsnapshot_value2"), SnapshotOriginList.get(1).getOrigin(),"验证Origin");
			Logger.verifyEquals(EnvSetup.getData("productsnapshot_value3"), SnapshotOriginList.get(2).getOrigin(),"验证Origin");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductSnapshotOriginList_002() {
		Logger.start(true,"获取商品产地信息快照列表-ProductVersionList空");
		try {
			//TODO 补全case代码
			
			List<ProductVersionDto> ProductVersionList = new ArrayList<>();			
			
			getproductsnapshotoriginlistBean.setProductVersionList(ProductVersionList);

			getproductsnapshotoriginlistCall.setData(getproductsnapshotoriginlistBean);
			getproductsnapshotoriginlistCall.callService();	
			
			Logger.verifyEquals("400", getproductsnapshotoriginlistCall.getString("Code"),"验证Code");
			Logger.verifyEquals("参数错误|ProductVersionList不能为空", getproductsnapshotoriginlistCall.getString("Msg"),"验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductSnapshotOriginList_003() {
		Logger.start(true,"获取商品产地信息快照列表-pid与version不匹配");
		try {
			//TODO 补全case代码
			
			List<ProductVersionDto> ProductVersionList = new ArrayList<>();
			
			ProductVersionDto productVersionDto1 = new ProductVersionDto();
			
			productVersionDto1.setProductId(EnvSetup.getData("productsnapshot_pid1"));
			productVersionDto1.setVersion("9.001");

			ProductVersionList.add(productVersionDto1);
			
			getproductsnapshotoriginlistBean.setProductVersionList(ProductVersionList);

			getproductsnapshotoriginlistCall.setData(getproductsnapshotoriginlistBean);
			getproductsnapshotoriginlistCall.callService();	
			
			Logger.verifyEquals("200", getproductsnapshotoriginlistCall.getString("Code"),"验证Code");
			
			List<ProductSnapshotOriginDto> SnapshotOriginList = getproductsnapshotoriginlistCall.getSnapshotOriginList().getSnapshotOriginList();
			
			Logger.verifyEquals(0, SnapshotOriginList.size(),"验证SnapshotOriginList");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductSnapshotOriginList_004() {
		Logger.start(true,"获取商品产地信息快照列表-ProductVersionList null");
		try {
			
			getproductsnapshotoriginlistCall.setData(getproductsnapshotoriginlistBean);
			getproductsnapshotoriginlistCall.callService();	
			
			Logger.verifyEquals("400", getproductsnapshotoriginlistCall.getString("Code"),"验证Code");
			Logger.verifyEquals("参数错误|ProductVersionList不能为空", getproductsnapshotoriginlistCall.getString("Msg"),"验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}